
let handleNavigationBar = require("../../utils/formatCurrency").handleNavigationBar;
let download = require("../../utils/formatCurrency").download;
const app = getApp();
Page({
  data: {
    balances: [],
    date:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
    })
    this.data.date = options.data;
    handleNavigationBar(app.globalData.company)
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/balances/finddetail',
      method: 'POST',
      header: {
        token: app.globalData.token,
        version: app.globalData.version
      },
      data: {
        accountBookId: app.globalData.accountBookId,
        endPeriod: options.data,
        startPeriod: options.data,
        buttonStatus:0,
        isBNLJ:1
      },
      success: function (res) {
        that.setData({
          balances: res.data.balances
        })
        setTimeout(()=>{
          wx.hideLoading()
        },500)
      }
    })
  },
  downLoad() {
    let url = app.globalData.url + 'api/export/pdf/balance?accountBookId=' + app.globalData.accountBookId + '&startPeriod=' + this.data.date + '&endPeriod=' + this.data.date + '&version=' + app.globalData.version + '&token=' + app.globalData.token
    download(url)
  }
})